const main = () => {
    if (!autoServiceStart(3)) {
        logd("自动化服务启动失败，无法执行脚本" + timeString())
        exit();
        return;
    }
    showLogWin();
    try {
        const asyncList = [
            execAsync(), execAsync(),
            execAsync(), execAsync(),
            execAsync(), execAsync(),
            execAsync(), execAsync(),
        ];
        const isAllStop = asyncList.filter(tid => thread.isCancelled(tid)).length === asyncList.length;
        while (!isAllStop) {
            if (isAllStop) {
                logd('程序结束' + timeString());
                break;
            }
        }
    } catch (e) {
        toast('出现错误:' + e + timeString());
    }
}

const execAsync = () => {
    const tid = thread.execAsync(() => {
        while (true) {
            logd("异步" + tid.substring(0, 4) + timeString());
            // jdMaoTai();
            wxRed();
            if (thread.isCancelled(tid)) {
                break;
            }
        }
    });
    return tid;
}

main();
